package controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
public class HelloController{

    @RequestMapping("/hello")
    public ModelAndView handleRequest(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse) throws Exception {
        ModelAndView mav = new ModelAndView("index");
        mav.addObject("message", "Hello Spring MVC");
        return mav;
    }

    @RequestMapping("/param")
    public ModelAndView getParam(@RequestParam String userName, @RequestParam String password) {
        ModelAndView mav = new ModelAndView("showLoginInfo");
        mav.addObject("name",userName);
        mav.addObject("password",password);
        return mav;
    }

    @Controller
    public class loginAction {
        @RequestMapping("/login")
        public ModelAndView login(String username, String password){
            return new ModelAndView("param");
        }
    }

    @RequestMapping("/jump")
    public ModelAndView jump() {
        ModelAndView mav = new ModelAndView("redirect:/hello");
        return mav;
    }


}
